<!DOCTYPE html>
<html>
<head>
    <title>所有主播</title>
    #parse("include/head.html")
</head>

<body>
<!--头部-->
#parse("include/nav.html")
<!--头部 end-->

<div class="container">
    <!--所有主播-->
    <div class="box-m">
        <div class="title-tab">
            <a id="rec" href="javascript:void(0)" onclick="showUsers('rec');" class="on">推荐排序</a>
            <a id="hot" href="javascript:void(0)" onclick="showUsers('hot');">人气排序</a>
        </div>
        <div class="index-anchor-list all-anchor">
            <div id="Containerflag"></div>
        </div>
    </div>
    <!--所有主播 end-->
</div>

<!--底部-->
#parse("include/footer.html")
<!--底部 end-->
#parse("include/libs.html")
<script src="$request.contextPath/res/plugin/laypage/laypage.js"></script>
<script>
    var curPage = 0;
    var isLastPage = false;
    var orderType = "rec";
    $(window).scroll(function () {
        var scrollTop = $(this).scrollTop();
        var scrollHeight = $(document).height();
        var windowHeight = $(this).height();
        if (scrollTop + windowHeight == scrollHeight) {
            if (!isLastPage) {
                getPageData(++curPage);
            } else {
                console.log("no data any more");
            }
        }
    });

    function showUsers(type) {
        if (type == 'hot') {
            $('#hot').addClass("on");
            $('#rec').removeClass("on");
            orderType = "hot";
        } else {
            $('#rec').addClass("on");
            $('#hot').removeClass("on");
            orderType = "rec";
        }
        $(".box-m dl").each(function(){
            $(this).remove();
        });
        curPage=1;
        getPageData(curPage);
    }

    function getPageData(curr){
        $.ajax({
            url: basePath+"/user/getBoboer",
            type: "POST",
            dataType: 'json',
            data: {
                "pgNum" : curr,
                "pgSize" : 12,
                "type" : 0,
                "orderType":orderType,
                "query" : null
            },
            success: function (data) {
                var brands = data["list"];
                isLastPage = data['isLastPage'];
                var str = "";
                for(var i in brands){
                    var kys = brands[i];
                    str += "<dl onclick=\"load('"+basePath+"/user/"+ kys['uid'] + "')\">";
                    str +=  "<dt> <img src=\""+kys['avatar']+"\"></dt>";
                    str +=  "<dd><h2>" + kys['nickname']+"</h2><span><i class='ico popular'></i>"+kys['followerCnt']+"</span></dd>";
                    str += "</dl>";
                }
                $("#Containerflag").before(str);
            },
            error:function(data){
                console.log('获取记录失败');
                layer.msg('获取记录失败！', {icon: 5});
            }
        });
    }

    $(document).ready(function() {
        updateNav("#bobonav");
        getPageData(++curPage);
    });
</script>

</body>
</html>
